<%@page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="com.ecp.pzh365.pay.Pkipair"%>
<%@page import="com.ecp.order.service.OrderService"%>
<%@page import="com.ecp.util.SpringUtil"%>
<%@page import="com.ecp.base.bean.Order"%>
<%@page import="com.ecp.base.service.PayRecService"%>
<%@page import="com.ecp.base.bean.PayRec"%>
<%@page import="com.ecp.util.DateUtil"%>
<%@page import="com.ecp.commons.Global"%>
<%@page import="com.ecp.pzh365.chargepay.service.ChargePayService" %>
<%@page import="com.ecp.order.service.DepositLogService" %>
<%@page import="com.ecp.order.bean.DepositLog" %>
<%@page import="com.ecp.util.SpringUtil" %>
<%@page import="com.ecp.pzh365.chargepay.service.WangYinPayService" %>
<jsp:useBean id="MD5" scope="request" class="beartool.MD5"/>

<%
//****************************************	// MD5密钥要跟订单提交页相同，如Send.asp里的 key = "test" ,修改""号内 test 为您的密钥
											// 如果您还没有设置MD5密钥请登陆我们为您提供商户后台，地址：https://merchant3.chinabank.com.cn/
String key = WangYinPayService.key;						// 登陆后在上面的导航栏里可能找到“B2C”，在二级导航栏里有“MD5密钥设置”
											// 建议您设置一个16位以上的密钥或更高，密钥最多64位，但设置16位已经足够了
//****************************************

//获取参数
	   String v_oid = request.getParameter("v_oid");		// 订单号
	 String v_pmode = request.getParameter("v_pmode");		// 支付方式中文说明，如"中行长城信用卡"
   String v_pstatus = request.getParameter("v_pstatus");	// 支付结果，20支付完成；30支付失败；
   String v_pstring = request.getParameter("v_pstring");	// 对支付结果的说明，成功时（v_pstatus=20）为"支付成功"，支付失败时（v_pstatus=30）为"支付失败"
	String v_amount = request.getParameter("v_amount");		// 订单实际支付金额
 String v_moneytype = request.getParameter("v_moneytype");	// 币种
	String v_md5str = request.getParameter("v_md5str");		// MD5校验码
	 String remark1 = request.getParameter("remark1");		// 备注1
	 if(remark1!=null){
		 remark1 = remark1.replaceAll("^\\d+@", "");
	 }
	 String remark2 = request.getParameter("remark2");		// 备注2

/*  System.out.println("===============用户点击回调start");
 System.out.println(v_oid);
 System.out.println(v_pmode);
 System.out.println(v_pstatus);
 System.out.println(v_pstring);
 System.out.println(v_amount);
 System.out.println(v_moneytype);
 System.out.println(v_md5str);
 System.out.println(remark1);
 System.out.println(remark2);
 System.out.println("===============用户点击回调end"); */

String text = v_oid+v_pstatus+v_amount+v_moneytype+key; //拼凑加密串
String v_md5text = MD5.getMD5ofStr(text).toUpperCase();
boolean paySuccess = false;

if (v_md5str.equals(v_md5text))
{
  // out.print("ok"); // 告诉服务器验证通过,停止发送
	String order = v_oid.split("-")[2];
	String rtnUrl = Global.SERVER_ADDR;
	rtnUrl = "";
	 DepositLog log = this.depositLogService.getByTransactionID(order);
   if ("20".equals(v_pstatus))
	{ 
	   paySuccess = true;
	   if(remark1.equals("yyg")){
			rtnUrl = rtnUrl + "/yyg/front/vipCenter/depositRechargeSuccess.jsp" + "?credit="+log.getCredit();
		} else rtnUrl = rtnUrl + "/pinzhiV2.0/mCenter/recharge/depositRechargeSuccess.jsp" + "?credit="+log.getCredit();
	}else if("30".equals(v_pstatus)){
		if(remark1.equals("yyg")){
			rtnUrl = rtnUrl + "/yyg/front/vipCenter/depositRechargeSuccess.jsp" + "?credit="+log.getCredit();
		} else rtnUrl = rtnUrl + "/pinzhiV2.0/mCenter/recharge/depositRechargeSuccess.jsp"+"?credit="+log.getCredit();
		paySuccess = false;
	}
%>
<%--重定向到展示的页面 --%>
<%-- <result>1</result>
<redirecturl><%=rtnUrl%></redirecturl> --%>
<script>
	window.location = "<%=rtnUrl%>";
</script>
<%
}else{//签名不正确的情况
	paySuccess = false;
}
%>

<%!
	DepositLogService depositLogService = (DepositLogService)SpringUtil.getBean("depositLogService");
%>